package com.cxh.mchat.bussiness.controller;


import com.baomidou.mybatisplus.extension.api.R;
import com.cxh.mchat.bussiness.bean.ConversationReqBean;
import com.cxh.mchat.bussiness.bean.ConversationRespBean;
import com.cxh.mchat.bussiness.entity.Conversation;
import com.cxh.mchat.bussiness.service.IConversationService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 对话 前端控制器
 * </p>
 *
 * @author cxh
 * @since 2021-12-28
 */
@RestController
@RequestMapping("/api/conversation")
public class ConversationController {

    @Resource
    private IConversationService conversationService;

    @GetMapping("/query")
    public R<List<ConversationRespBean>> queryList(ConversationReqBean reqBean){
        return R.ok(conversationService.queryRespList(reqBean));
    }

    @PostMapping("/add")
    public R<Boolean> add(@RequestBody @Validated Conversation reqBean){
        return R.ok(conversationService.add(reqBean));
    }
}
